package com.example.springbootspidemo;

import com.example.springbootspidemo.service.MessageService;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.core.io.support.SpringFactoriesLoader;

import java.util.List;

@SpringBootApplication
public class SpringBootSpiDemoApplication {

    public static void main(String[] args) {
        // loadFactories() 的第二个参数是类加载器，此处我们使用默认的类加载器，所以传递 null
        List<MessageService> services = SpringFactoriesLoader.loadFactories(MessageService.class, null);
        for (MessageService service : services) {
            System.out.println(service.getMessage());
        }
    }

}
